package com.shopping.servlet.order;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.shopping.pojo.Order;
import com.shopping.service.OrderService;
import com.shopping.service.impl.OrderServiceImpl;

@WebServlet("/QueryOrderServlet")
public class QueryOrderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("html/text;charset=utf-8");
		PrintWriter out = response.getWriter();
		int page = Integer.valueOf(request.getParameter("page"));
		int limit = Integer.valueOf(request.getParameter("limit"));
		OrderService os = new OrderServiceImpl();
		ArrayList<Order> list = os.getOrderPage(page, limit);
		long count = os.getTotalData();
		JSONObject jo = new JSONObject();
		jo.put("code", 0);
		jo.put("msg","");
		jo.put("count", count);
		jo.put("data", list);
		System.out.println(jo);
		out.print(jo);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
